<div id="maincontent">

<%= render :partial => "shared_common_files/data_area_help_bar" %>

<h2>Feed > Feed Delivery </h2>

    <% if(@feedeliverytypes!=nil and @feedenewsletters!=nil)%>
        <h5>Select your delivery type, and delivery template and click on "Start delivery" button</h5>
    <%else%>
        <h5>You can schedule feed delivery by clicking on "Delivery" icon</h5>	
    <%end%>
  
    <% for name in [:notice, :warning, :message] %>
        <% if flash[name] %>
            <%= "<div class='message-fatal'> #{flash[name]} </div>" %>
        <% end %>
    <% end %>
  
<% if(@feedsubscribers==nil and @showFeedList)%>
    
    <div class="list">
	    <table>
		    <tr>
			     <td class="pagination" colspan="5"> <!-- pagination will be here --> <%=pagination_links @feed_pages%></td>
		    </tr>

        <% count=1;%>
        
        <% for column in Feed.content_columns %>
            <%if(column.human_name!='Guid')%>
                <th><%= column.human_name %></th>
            <% end %>
        <% end %>		
 
        <th>Action</th>

        <% count=1;%>	  
        <% rowtype="odd";%>

        <% for entry in @feeds %>
            <%if(isodd(count))%>
                <% rowtype="odd";%>
            <%else%>
                <% rowtype="even";%>
            <%end%>     
  
            <tr class="<%=rowtype%>">
                <% for column in Feed.content_columns %>
                    <%if(column.human_name!='Guid')%>
                        <td>
                        <% if column.name == "feed_url"%>
                            <a href=<%= entry.send(column.name)%>><%=entry.send(column.name)%></a>
                        <%else%>
                            <%= entry.send(column.name) %>
                        <%end%>
                        </td>
                    <% end %>
                <% end %>
                <td>
                    <%= link_to image_tag('/themes/odotclassic/images/deliver-feed.png', :title => 'Delivery'), :action => "deliverylist", :feedid => entry %>
                </td>
            </tr>
            
            <% count = count + 1 %>
        <% end %>

		</table>
    </div>

    <br /><br /><br />

    <div class="list">
        <%= start_form_tag({:action => ''}, :method=>'get') %>
	    
	    <table>
	        <th>Action</th>
                <tr class="even">
                    <td>
                        <!-- %= link_if_authorized submit_tag('Cancel'), {:action => 'list'}  % -->
                        <%= link_if_authorized image_tag('/themes/odotclassic/images/btn_cancel.gif', :alt => 'Cancel' ), {:action => 'list'}%>
                    </td>
                </tr>        
	    </table>
	    
	    <%= end_form_tag %>
    </div>

<%end%>

<%= start_form_tag( {:action => 'deliverylist'}) %>

<% if(@feedeliverytypes!=nil and @feedenewsletters!=nil)%>

<h3>Deliver <a href = <%=@feed.feed_url%>><%=@feed.feed_url%></a> to your subscribers</h3>

    <div class="message-information">
	    <div class="message-information">
            Select Delivery Type: 
            <select name="feeddeliverytype">
            
            <% for entry_feed_delivery_type in @feedeliverytypes %>
                <option value="<%=entry_feed_delivery_type.id%>"><%=entry_feed_delivery_type.delivery_type%> </option>
            <%end%>
            
            </select>    
        </div>
  
		<div class="message-error">
	        Select Delivery template:
            <select name="feeddeliverytemplate">
            
            <% for entry_feed_delivery_template in @feedenewsletters %>
                <option value="<%=entry_feed_delivery_template.id%>"><%=entry_feed_delivery_template.name%> </option>
            <%end%>
            
            </select>
        </div>
  
        <%= hidden_field_tag "feedid", @feedid%>
        <%= hidden_field_tag "op", "startdelivery"%>
  
        <%= image_submit_tag "/themes/odotclassic/images/btn_startsendingfeed.gif", :border => 0 %>
  
  <%= end_form_tag %>   

</div>

<h3>You can deliver this feed right now, simply click on 
<%= link_to image_tag('/themes/odotclassic/images/btn_sendfeednow.gif'),  {:action => 'deliver_now', :feedid => @feedid}, {:confirm => "Are you sure want to deliver your feed now?"} %>

</h3>
 <br /><br /><br />

    <div class="list">
        
    	<table>
    	     <th>Actions</th>
             <tr class="even">
                <td>
                                       
                    <%= link_if_authorized image_tag('/themes/odotclassic/images/btn_listfeeds.png', :alt => 'List' ), {:action => 'list'}%>
                    <%= link_if_authorized image_tag('/themes/odotclassic/images/btn_cancel.gif', :alt => 'Cancel' ), {:action => 'deliverylist'}%>
                    
                </td>
             </tr>        
    	</table>
    	
    </div>
    
 <%end%>

<% if(@savemessage!=nil)%>
<h3><%=@savemessage%></h3>
<%end%>
 
 

</div>